<div class="tabbable tabs-left">
    <ul class="nav nav-tabs">
        <li><h5><?php echo $this->translate('广告编辑'); ?></h5></li>
        <li class="active"><a data-toggle="tab" href="#ad_a"><?php echo $this->translate('基本信息'); ?></a></li>
    </ul>
    <form class="form-horizontal" name="ad_form" id="ad_form" method="post" enctype="multipart/form-data" action="">
        <input type="hidden" name="item_id" id="item_id" value="<?php echo $this->item_info->item_id; ?>" />
        <input type="hidden" name="theme_ad_id" id="theme_ad_id" value="<?php echo isset($this->ad['theme_ad_id']) ? $this->ad['theme_ad_id'] : ''; ?>">
        <div class="tab-content">
            <div id="sticky_navigation" style="height:30px;border-bottom:4px solid #DFDFDF;">
                <div class="pull-left" style="font-size:16px;line-height:30px;"><strong><?php echo $this->translate('广告编辑'); ?></strong></div>
                <div class="pull-right">
                    <a href="<?php echo $this->url('admintheme/default', array('action'=>'adList'), array('query'=>array('theme_id'=>$this->item_info->theme_id))); ?>" class="btn btn-small"><i class="icon-arrow-left"></i> <?php echo $this->translate('返回广告设置'); ?></a>&nbsp;
                    <a href="<?php echo $this->serverUrl(true); ?>" class="btn btn-small btn-warning"><i class="icon-repeat icon-white"></i> <?php echo $this->translate('刷新'); ?></a>&nbsp;
                    <button type="submit" class="btn btn-small btn-primary"><i class="icon-ok icon-white"></i> <?php echo $this->translate('保存广告信息'); ?></button>&nbsp;
                </div>
            </div>
            <div id="ad_a" class="tab-pane active">
                <div class="well admin_add_header_well"><?php echo $this->translate('基本信息'); ?></div>
                <div class="well admin_add_well">
                    <div class="message_one">
                    </div>
                    <div class="control-group">
                        <label for="input01" class="control-label"><?php echo $this->translate('广告名称'); ?>：</label>
                        <div class="controls">
                            <label style="line-height: 28px;"><?php echo $this->item_info->item_title; ?></label>
                        </div>
                    </div>
                    <div class="control-group">
                        <label for="input01" class="control-label"><?php echo $this->translate('广告类型'); ?>：</label>
                        <div class="controls">
                            <label style="line-height: 28px;"><?php
                                switch ($this->ad_ini[$this->item_info->item_code]['type']) {
                                    case 'image':
                                        echo $this->translate('图片');
                                        break;
                                    case 'text':
                                        echo $this->translate('文字');
                                        break;
                                    case 'code':
                                        echo $this->translate('代码');
                                        break;
                                    case 'slide':
                                        echo $this->translate('幻灯片');
                                        break;
                                }
                                ?></label>
                            <input type="hidden" name="theme_ad_type" value="<?php echo $this->ad_ini[$this->item_info->item_code]['type']; ?>">
                        </div>
                    </div>
                    <?php if(isset($this->ad_ini[$this->item_info->item_code]['size'])) { ?>
                    <div class="control-group">
                        <label for="input01" class="control-label"><?php echo $this->translate('推荐尺寸'); ?>：</label>
                        <div class="controls">
                            <label style="line-height: 28px;"><?php echo $this->ad_ini[$this->item_info->item_code]['size']; ?></label>
                        </div>
                    </div>
                    <?php } ?>
                    <?php if($this->ad_ini[$this->item_info->item_code]['type'] == 'image') { ?>
                    <div class="control-group ad_type_class ad_image">
                        <label for="input01" class="control-label"><?php echo $this->translate('广告图片'); ?>：</label>
                        <div class="controls">
                            <?php if(!empty($this->ad['theme_ad_body'])) { ?>
                                <img src="<?php echo $this->basePath($this->ad['theme_ad_body']); ?>" border="0" style="max-width:500px;" />
                                <input type="hidden" name="old_ad_image" value="<?php echo $this->ad['theme_ad_body']; ?>" />
                                <br />
                            <?php } ?>
                            <input type="file" name="ad_image" />
                        </div>
                    </div>
                    <?php } ?>

                    <?php if($this->ad_ini[$this->item_info->item_code]['type'] == 'text') { ?>
                    <div class="control-group ad_type_class ad_text">
                        <label for="input01" class="control-label"><?php echo $this->translate('广告文字'); ?>：</label>
                        <div class="controls">
                            <script type="text/plain" id="ad_text" name="ad_text"><?php if(isset($this->ad['theme_ad_type']) and $this->ad['theme_ad_type'] == 'text') echo $this->ad['theme_ad_body'] ?></script>
                        </div>
                    </div>
                    <?php } ?>

                    <?php if($this->ad_ini[$this->item_info->item_code]['type'] == 'code') { ?>
                    <div class="control-group ad_type_class ad_code">
                        <label for="input01" class="control-label"><?php echo $this->translate('广告代码'); ?>：</label>
                        <div class="controls">
                            <textarea class="span6" name="ad_code" id="ad_code" rows="3"><?php if(isset($this->ad['theme_ad_type']) and $this->ad['theme_ad_type'] == 'code') echo $this->ad['theme_ad_body']; ?></textarea>
                        </div>
                    </div>
                    <?php } ?>

                    <?php if($this->ad_ini[$this->item_info->item_code]['type'] == 'slide') { ?>
                    <div class="control-group ad_type_class ad_slide">
                        <label for="input01" class="control-label"><?php echo $this->translate('幻灯片图片1'); ?>：</label>
                        <div class="controls">
                            <?php $slide_content_0 = false; if($this->slide_array and !empty($this->slide_array[0])) { $slide_content_0 = true;
                                $file1_md5_str = md5($this->slide_array[0]['theme_ad_slide_image']);
                                ?>
                                <img class="<?php echo $file1_md5_str; ?>" src="<?php echo $this->basePath($this->slide_array[0]['theme_ad_slide_image']); ?>" border="0" style="max-width:500px;" />
                                <a href="javascript:;" class="badge badge-important <?php echo$file1_md5_str; ?>" onclick="del_slide_image(<?php echo $this->ad['theme_ad_id']; ?>, '<?php echo $this->slide_array[0]['theme_ad_slide_image']; ?>');" title="<?php echo $this->translate('删除图片'); ?>">X</a>
                                <input class="<?php echo $file1_md5_str; ?>" type="hidden" name="old_ad_slide_image_1" value="<?php echo $this->slide_array[0]['theme_ad_slide_image']; ?>" />
                                <br class="<?php echo $file1_md5_str; ?>" />
                            <?php } ?>
                            <input type="file" name="ad_slide_image_1" />
                        </div>
                    </div>
                    <div class="control-group ad_type_class ad_slide">
                        <label for="input01" class="control-label"><?php echo $this->translate('显示文字1'); ?>：</label>
                        <div class="controls">
                            <textarea class="span6" name="ad_slide_text_1" rows="2"><?php if($slide_content_0) echo $this->slide_array[0]['theme_ad_slide_info']; ?></textarea>
                        </div>
                    </div>
                    <div class="control-group ad_type_class ad_slide">
                        <label for="input01" class="control-label"><?php echo $this->translate('链接地址1'); ?>：</label>
                        <div class="controls">
                            <input type="text"  name="ad_slide_url_1" class="span8" value="<?php if($slide_content_0) echo $this->slide_array[0]['theme_ad_slide_url']; ?>">
                        </div>
                    </div>
                    <div class="control-group ad_type_class ad_slide">
                        <label for="input01" class="control-label"><?php echo $this->translate('排序1'); ?>：</label>
                        <div class="controls">
                            <input type="text" name="ad_slide_sort_1" value="<?php echo ($slide_content_0 ? $this->slide_array[0]['theme_ad_slide_sort'] : 1); ?>" class="span1" />
                        </div>
                    </div>
                    <div class="control-group ad_type_class ad_slide">
                        <label for="input01" class="control-label"><?php echo $this->translate('幻灯片图片2'); ?>：</label>
                        <div class="controls">
                            <?php $slide_content_1 = false; if($this->slide_array and !empty($this->slide_array[1])) { $slide_content_1 = true;
                                $file2_md5_str = md5($this->slide_array[1]['theme_ad_slide_image']);
                                ?>
                                <img class="<?php echo $file2_md5_str; ?>" src="<?php echo $this->basePath($this->slide_array[1]['theme_ad_slide_image']); ?>" border="0" style="max-width:500px;" />
                                <a href="javascript:;" class="badge badge-important <?php echo $file2_md5_str; ?>" onclick="del_slide_image(<?php echo $this->ad['theme_ad_id']; ?>, '<?php echo $this->slide_array[1]['theme_ad_slide_image']; ?>');" title="<?php echo $this->translate('删除图片'); ?>">X</a>
                                <input class="<?php echo $file2_md5_str; ?>" type="hidden" name="old_ad_slide_image_2" value="<?php echo $this->slide_array[1]['theme_ad_slide_image']; ?>" />
                                <br class="<?php echo $file2_md5_str; ?>" />
                            <?php } ?>
                            <input type="file" name="ad_slide_image_2" />
                        </div>
                    </div>
                    <div class="control-group ad_type_class ad_slide">
                        <label for="input01" class="control-label"><?php echo $this->translate('显示文字2'); ?>：</label>
                        <div class="controls">
                            <textarea class="span6" name="ad_slide_text_2" rows="2"><?php if($slide_content_1) echo $this->slide_array[1]['theme_ad_slide_info']; ?></textarea>
                        </div>
                    </div>
                    <div class="control-group ad_type_class ad_slide">
                        <label for="input01" class="control-label"><?php echo $this->translate('链接地址2'); ?>：</label>
                        <div class="controls">
                            <input type="text"  name="ad_slide_url_2" class="span8" value="<?php if($slide_content_1) echo $this->slide_array[1]['theme_ad_slide_url']; ?>">
                        </div>
                    </div>
                    <div class="control-group ad_type_class ad_slide">
                        <label for="input01" class="control-label"><?php echo $this->translate('排序2'); ?>：</label>
                        <div class="controls">
                            <input type="text" name="ad_slide_sort_2" value="<?php echo ($slide_content_1 ? $this->slide_array[1]['theme_ad_slide_sort'] : 2); ?>" class="span1" />
                        </div>
                    </div>
                    <div class="control-group ad_type_class ad_slide">
                        <label for="input01" class="control-label"><?php echo $this->translate('幻灯片图片3'); ?>：</label>
                        <div class="controls">
                            <?php $slide_content_2 = false; if($this->slide_array and !empty($this->slide_array[2])) { $slide_content_2 = true;
                                $file3_md5_str = md5($this->slide_array[2]['theme_ad_slide_image']);
                                ?>
                                <img class="<?php echo $file3_md5_str; ?>" src="<?php echo $this->basePath($this->slide_array[2]['theme_ad_slide_image']); ?>" border="0" style="max-width:500px;" />
                                <a href="javascript:;" class="badge badge-important <?php echo $file3_md5_str; ?>" onclick="del_slide_image(<?php echo $this->ad['theme_ad_id']; ?>, '<?php echo $this->slide_array[2]['theme_ad_slide_image']; ?>');" title="<?php echo $this->translate('删除图片'); ?>">X</a>
                                <input class="<?php echo $file3_md5_str; ?>" type="hidden" name="old_ad_slide_image_3" value="<?php echo $this->slide_array[2]['theme_ad_slide_image']; ?>" />
                                <br class="<?php echo $file3_md5_str; ?>" />
                            <?php } ?>
                            <input type="file" name="ad_slide_image_3" />
                        </div>
                    </div>
                    <div class="control-group ad_type_class ad_slide">
                        <label for="input01" class="control-label"><?php echo $this->translate('显示文字3'); ?>：</label>
                        <div class="controls">
                            <textarea class="span6" name="ad_slide_text_3" rows="2"><?php if($slide_content_2) echo $this->slide_array[2]['theme_ad_slide_info']; ?></textarea>
                        </div>
                    </div>
                    <div class="control-group ad_type_class ad_slide">
                        <label for="input01" class="control-label"><?php echo $this->translate('链接地址3'); ?>：</label>
                        <div class="controls">
                            <input type="text"  name="ad_slide_url_3" class="span8" value="<?php if($slide_content_2) echo $this->slide_array[2]['theme_ad_slide_url']; ?>">
                        </div>
                    </div>
                    <div class="control-group ad_type_class ad_slide">
                        <label for="input01" class="control-label"><?php echo $this->translate('排序3'); ?>：</label>
                        <div class="controls">
                            <input type="text" name="ad_slide_sort_3" value="<?php echo ($slide_content_2 ? $this->slide_array[2]['theme_ad_slide_sort'] : 3); ?>" class="span1" />
                        </div>
                    </div>
                    <div class="control-group ad_type_class ad_slide">
                        <label for="input01" class="control-label"><?php echo $this->translate('幻灯片图片4'); ?>：</label>
                        <div class="controls">
                            <?php $slide_content_3 = false; if($this->slide_array and !empty($this->slide_array[3])) { $slide_content_3 = true;
                                $file4_md5_str = md5($this->slide_array[3]['theme_ad_slide_image']);
                                ?>
                                <img class="<?php echo $file4_md5_str; ?>" src="<?php echo $this->basePath($this->slide_array[3]['theme_ad_slide_image']); ?>" border="0" style="max-width:500px;" />
                                <a href="javascript:;" class="badge badge-important <?php echo $file4_md5_str; ?>" onclick="del_slide_image(<?php echo $this->ad['theme_ad_id']; ?>, '<?php echo $this->slide_array[3]['theme_ad_slide_image']; ?>');" title="<?php echo $this->translate('删除图片'); ?>">X</a>
                                <input class="<?php echo $file4_md5_str; ?>" type="hidden" name="old_ad_slide_image_4" value="<?php echo $this->slide_array[3]['theme_ad_slide_image']; ?>" />
                                <br class="<?php echo $file4_md5_str; ?>" />
                            <?php } ?>
                            <input type="file" name="ad_slide_image_4" />
                        </div>
                    </div>
                    <div class="control-group ad_type_class ad_slide">
                        <label for="input01" class="control-label"><?php echo $this->translate('显示文字4'); ?>：</label>
                        <div class="controls">
                            <textarea class="span6" name="ad_slide_text_4" rows="2"><?php if($slide_content_3) echo $this->slide_array[3]['theme_ad_slide_info']; ?></textarea>
                        </div>
                    </div>
                    <div class="control-group ad_type_class ad_slide">
                        <label for="input01" class="control-label"><?php echo $this->translate('链接地址4'); ?>：</label>
                        <div class="controls">
                            <input type="text"  name="ad_slide_url_4" class="span8" value="<?php if($slide_content_3) echo $this->slide_array[3]['theme_ad_slide_url']; ?>">
                        </div>
                    </div>
                    <div class="control-group ad_type_class ad_slide">
                        <label for="input01" class="control-label"><?php echo $this->translate('排序4'); ?>：</label>
                        <div class="controls">
                            <input type="text" name="ad_slide_sort_4" value="<?php echo ($slide_content_3 ? $this->slide_array[3]['theme_ad_slide_sort'] : 4); ?>" class="span1" />
                        </div>
                    </div>
                    <div class="control-group ad_type_class ad_slide">
                        <label for="input01" class="control-label"><?php echo $this->translate('幻灯片图片5'); ?>：</label>
                        <div class="controls">
                            <?php $slide_content_4 = false; if($this->slide_array and !empty($this->slide_array[4])) { $slide_content_4 = true;
                                $file5_md5_str = md5($this->slide_array[4]['theme_ad_slide_image']);
                                ?>
                                <img class="<?php echo $file5_md5_str; ?>" src="<?php echo $this->basePath($this->slide_array[4]['theme_ad_slide_image']); ?>" border="0" style="max-width:500px;" />
                                <a href="javascript:;" class="badge badge-important <?php echo $file5_md5_str; ?>" onclick="del_slide_image(<?php echo $this->ad['theme_ad_id']; ?>, '<?php echo $this->slide_array[4]['theme_ad_slide_image']; ?>');" title="<?php echo $this->translate('删除图片'); ?>">X</a>
                                <input class="<?php echo $file5_md5_str; ?>" type="hidden" name="old_ad_slide_image_5" value="<?php echo $this->slide_array[4]['theme_ad_slide_image']; ?>" />
                                <br class="<?php echo $file5_md5_str; ?>" />
                            <?php } ?>
                            <input type="file" name="ad_slide_image_5" />
                        </div>
                    </div>
                    <div class="control-group ad_type_class ad_slide">
                        <label for="input01" class="control-label"><?php echo $this->translate('显示文字5'); ?>：</label>
                        <div class="controls">
                            <textarea class="span6" name="ad_slide_text_5" rows="2"><?php if($slide_content_4) echo $this->slide_array[4]['theme_ad_slide_info']; ?></textarea>
                        </div>
                    </div>
                    <div class="control-group ad_type_class ad_slide">
                        <label for="input01" class="control-label"><?php echo $this->translate('链接地址5'); ?>：</label>
                        <div class="controls">
                            <input type="text"  name="ad_slide_url_5" class="span8" value="<?php if($slide_content_4) echo $this->slide_array[4]['theme_ad_slide_url']; ?>">
                        </div>
                    </div>
                    <div class="control-group ad_type_class ad_slide">
                        <label for="input01" class="control-label"><?php echo $this->translate('排序5'); ?>：</label>
                        <div class="controls">
                            <input type="text" name="ad_slide_sort_5" value="<?php echo ($slide_content_4 ? $this->slide_array[4]['theme_ad_slide_sort'] : 5); ?>" class="span1" />
                        </div>
                    </div>
                    <?php } else { ?>
                    <div class="control-group ad_url">
                        <label for="input01" class="control-label"><?php echo $this->translate('广告URL地址'); ?>：</label>
                        <div class="controls">
                            <input type="text" id="theme_ad_url"  name="theme_ad_url" class="span8" value="<?php echo (($this->ad and isset($this->ad['theme_ad_url'])) ? $this->escapeHtml($this->ad['theme_ad_url']) : ''); ?>">
                        </div>
                    </div>
                    <?php } ?>
                </div>
            </div>


        </div>
    </form>
</div>
<?php if($this->ad_ini[$this->item_info->item_code]['type'] == 'text') echo $this->partial('common/editor',array('edit_array'=>array('ad_text'),
    'edit_config'=>array(
        "toolbars:[['FullScreen', 'Source', 'Undo', 'Redo','Bold']]",
        "wordCount:false",
        "initialFrameHeight:100",
        "elementPathEnabled:false",
        "maximumWords:500"
    )));
?>
<script>
    function del_slide_image(theme_ad_id, image_path) {
        if(window.confirm('<?php echo $this->translate('您确实要删除该图片吗？'); ?>')) {
            $.post("<?php echo $this->url('admintheme/default',array('action'=>'delSlideImage')); ?>",{theme_ad_id:theme_ad_id,image_path:image_path},
                function(data){
                    if(data != 'false') {
                        $('.'+data).remove();
                        return true;
                    } else {
                        alert('<?php echo $this->translate('图片删除失败！'); ?>');
                    }
                });
        }
        return false;
    }
    <?php if ($this->success_msg != '') { ?>
    show_message('.message_one','<?php echo date("Y-m-d H:i:s",time()); ?>','<?php echo $this->success_msg; ?>','alert-success');
    <?php } ?>
</script>